package de.tu_darmstadt.gdi1.xcom.tests.testcases.tutors;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import de.tu_darmstadt.gdi1.xcom.tests.adapters.XcomTestAdapterLevel3;

/**
 * 
 * Tests for "easy" light of sight
 * 
 * @author Lukas Schwoebel
 *
 */
public class HeavyLineOfSightTest {
	
	private XcomTestAdapterLevel3 testAdapter;

	private final String lineOfSightLevel = "" +
			"##############\n" +
			"##..........##\n" +
			"##...##.....##\n" +
			"##..........##\n" +
			"####.......###\n" +
			"#....##.....##\n" +
			"#...........##\n" +
			"#...........##\n" +
			"#...........##\n" +
			"#...........##\n" +
			"##############\n" +
			"//{mobs}\n" +
			"//@;5;3;w;50;75;50;50;10";
	
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		testAdapter = new XcomTestAdapterLevel3();
	}

	/**
	 * Test method for {@link de.tu_darmstadt.gdi1.xcom.tests.adapters.XcomTestAdapterLevel3#isFieldVisible()}.
	 */
	@Test
	public final void testIsFieldVisible() {
		
		testAdapter.loadLevelFromString(lineOfSightLevel);
		
		// player is looking west, so only fields west of the player should be visible
		assertTrue("Field 6:3 should be visible", testAdapter.isFieldVisible(4, 3));
		assertTrue("Field 7:3 should be visible", testAdapter.isFieldVisible(3, 3));
		assertTrue("Field 7:4 should be visible", testAdapter.isFieldVisible(3, 4));
		
		// fields west of player are invisible
		assertFalse("Field 6:1 should be hidden", testAdapter.isFieldVisible(6, 1));
		assertFalse("Field 6:2 should be hidden", testAdapter.isFieldVisible(6, 2));
		assertFalse("Field 6:3 should be hidden", testAdapter.isFieldVisible(6, 3));
		assertFalse("Field 6:4 should be hidden", testAdapter.isFieldVisible(6, 4));
		assertFalse("Field 6:2 should be hidden", testAdapter.isFieldVisible(7, 2));
		assertFalse("Field 6:3 should be hidden", testAdapter.isFieldVisible(7, 3));
		assertFalse("Field 6:4 should be hidden", testAdapter.isFieldVisible(7, 4));
		assertFalse("Field 6:3 should be hidden", testAdapter.isFieldVisible(8, 3));
		
		// fields behind wall
		assertFalse("Field 1:5 should be hidden", testAdapter.isFieldVisible(1, 5));
		assertFalse("Field 5:1 should be hidden", testAdapter.isFieldVisible(5, 1));
	}
}
